﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;

namespace LojaEmDia
{
    internal class Util
    {
        internal static void ExibeAlerta(string mensagem)
        {
            MessageBox.Show(mensagem, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        internal static void DateTimeToString(object sender, ConvertEventArgs cevent)
        {
            if (cevent.DesiredType != typeof(string)) return;

            if (cevent.Value == null)
                return;
            else
                cevent.Value = ((DateTime)cevent.Value).ToString("dd/MM/yyyy");
        }

        internal static void StringToDateTime(object sender, ConvertEventArgs cevent)
        {
            if (cevent.DesiredType != typeof(DateTime)) return;
            if(cevent.Value == null) return;
            // Converts the string back to decimal using the static Parse method.
            cevent.Value = Convert.ToDateTime(cevent.Value.ToString(), new CultureInfo("pt-BR"));
        }



        internal static void ExibeErro(string mensagem)
        {
            MessageBox.Show(mensagem, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}
